[MISC] Add miss Type2Str and remove compile warnings#10430
Merged
Conversation
pfk-beta
pushed a commit
to pfk-beta/tvm
that referenced
this pull request
Apr 11, 2022
* [MISC] Add miss Type2Str and remove compile warnings * fix lint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After #10326, we now require the argument type of PackFunc to have a corresponding template of Type2Str. Otherwise we will get the following error during compilation (note that my argument type is
DLDataType).This PR adds a Type2Str template for DLDataType to remove my blocker. However, this doesn't solve the root problem. Ideally, we should not error out only if the Type2Str template is missing but the argument type of a PackFunc is actually supported. A straightforward solution to this issue is adding all templates for the types supported by TVMArgValue (e.g., intX_t, uintX_t for X in 8, 16, 32, 64; basically everything covered in https://github.com/apache/tvm/blob/main/include/tvm/runtime/packed_func.h#L1225). While it is tedious, I'm wondering if we could have a default template that simply prints "unknown_type" for non-ObjectRef types. It might be possible to leverage
std::enable_if_t<!std::is_base_of<ObjectRef, T>::value>, but I'm not sure how to achieve it in the case of Type2Str struct.(nit) In addition, this PR also removes some compiler warnings reported by Clang:
size_tis always larger or equal than zero, so no need to checkidx >= 0.cc @cyx-6 @junrushao1994